<!DOCTYPE html>
<html lang="en">
  <head>
    <title>AnyDifferentiable Structure Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset="utf-8">
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
    <script src="../js/lunr.min.js" defer></script>
    <script src="../js/typeahead.jquery.js" defer></script>
    <script src="../js/jazzy.search.js" defer></script>
  </head>
  <body>

    <a name="//apple_ref/swift/Struct/AnyDifferentiable" class="dashAnchor"></a>

    <a title="AnyDifferentiable Structure Reference"></a>

    <header class="header">
      <p class="header-col header-col--primary">
        <a class="header-link" href="../index.html">
          DifferenceKit Docs
        </a>
         (100% documented)
      </p>
    
      <p class="header-col--secondary">
        <form role="search" action="../search.json">
          <input type="text" placeholder="Search documentation" data-typeahead>
        </form>
      </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="https://github.com/ra1028/DifferenceKit">
            <img class="header-icon" src="../img/gh.png"/>
            View on GitHub
          </a>
        </p>
    
    </header>

    <p class="breadcrumbs">
      <a class="breadcrumb" href="../index.html">DifferenceKit Reference</a>
      <img class="carat" src="../img/carat.png" />
      AnyDifferentiable Structure Reference
    </p>

    <div class="content-wrapper">
      <nav class="navigation">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Diffing.html">Diffing</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Protocols/ContentEquatable.html">ContentEquatable</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Protocols/Differentiable.html">Differentiable</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Protocols/DifferentiableSection.html">DifferentiableSection</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/AnyDifferentiable.html">AnyDifferentiable</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/ArraySection.html">ArraySection</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/ElementPath.html">ElementPath</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Extensions/Optional.html">Optional</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Changeset.html">Changeset</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/StagedChangeset.html">StagedChangeset</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/Changeset.html">Changeset</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../UI%20Extensions.html">UI Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Extensions/UITableView.html">UITableView</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Extensions/UICollectionView.html">UICollectionView</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">

        <section class="section">
          <div class="section-content">
            <h1>AnyDifferentiable</h1>
              <div class="declaration">
                <div class="language">
                  <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">AnyDifferentiable</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/Differentiable.html">Differentiable</a></span></code></pre>

                </div>
              </div>
            <p>A type-erased differentiable value.</p>

<p>The <code>AnyDifferentiable</code> type hides the specific underlying types.
Associated type <code>DifferenceIdentifier</code> is erased by <code>AnyHashable</code>.
The comparisons of whether has updated is forwards to an underlying differentiable value.</p>

<p>You can store mixed-type elements in collection that require <code><a href="../Protocols/Differentiable.html">Differentiable</a></code> conformance by
wrapping mixed-type elements in <code>AnyDifferentiable</code>:</p>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt">String</span><span class="p">:</span> <span class="kt">Differentiable</span> <span class="p">{}</span>
<span class="kd">extension</span> <span class="kt">Int</span><span class="p">:</span> <span class="kt">Differentiable</span> <span class="p">{}</span>

<span class="k">let</span> <span class="nv">source</span> <span class="o">=</span> <span class="p">[</span>
    <span class="kt">AnyDifferentiable</span><span class="p">(</span><span class="s">"ABC"</span><span class="p">),</span>
    <span class="kt">AnyDifferentiable</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="p">]</span>
<span class="k">let</span> <span class="nv">target</span> <span class="o">=</span> <span class="p">[</span>
    <span class="kt">AnyDifferentiable</span><span class="p">(</span><span class="s">"ABC"</span><span class="p">),</span>
    <span class="kt">AnyDifferentiable</span><span class="p">(</span><span class="mi">100</span><span class="p">),</span>
    <span class="kt">AnyDifferentiable</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span>
<span class="p">]</span>

<span class="k">let</span> <span class="nv">changeset</span> <span class="o">=</span> <span class="kt">StagedChangeset</span><span class="p">(</span><span class="nv">source</span><span class="p">:</span> <span class="n">source</span><span class="p">,</span> <span class="nv">target</span><span class="p">:</span> <span class="n">target</span><span class="p">)</span>
<span class="nf">print</span><span class="p">(</span><span class="n">changeset</span><span class="o">.</span><span class="n">isEmpty</span><span class="p">)</span>  <span class="c1">// prints "false"</span>
</code></pre>

          </div>
        </section>

        <section class="section">
          <div class="section-content">
            <div class="task-group">
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:13DifferenceKit17AnyDifferentiableV4baseypvp"></a>
                    <a name="//apple_ref/swift/Property/base" class="dashAnchor"></a>
                    <a class="token" href="#/s:13DifferenceKit17AnyDifferentiableV4baseypvp">base</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The value wrapped by this instance.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@inlinable</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">base</span><span class="p">:</span> <span class="kt">Any</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:13DifferenceKit17AnyDifferentiableV20differenceIdentifiers0C8HashableVvp"></a>
                    <a name="//apple_ref/swift/Property/differenceIdentifier" class="dashAnchor"></a>
                    <a class="token" href="#/s:13DifferenceKit17AnyDifferentiableV20differenceIdentifiers0C8HashableVvp">differenceIdentifier</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>A type-erased identifier value for difference calculation.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@inlinable</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">differenceIdentifier</span><span class="p">:</span> <span class="kt">AnyHashable</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:13DifferenceKit17AnyDifferentiableVyACxcAA0D0Rzlufc"></a>
                    <a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:13DifferenceKit17AnyDifferentiableVyACxcAA0D0Rzlufc">init(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Creates a type-erased differentiable value that wraps the given instance.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@inlinable</span>
<span class="kd">public</span> <span class="kd">init</span><span class="o">&lt;</span><span class="kt">D</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">base</span><span class="p">:</span> <span class="kt">D</span><span class="p">)</span> <span class="k">where</span> <span class="kt">D</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/Differentiable.html">Differentiable</a></span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>base</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A differentiable value to wrap.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:13DifferenceKit17AnyDifferentiableV14isContentEqual2toSbAC_tF"></a>
                    <a name="//apple_ref/swift/Method/isContentEqual(to:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:13DifferenceKit17AnyDifferentiableV14isContentEqual2toSbAC_tF">isContentEqual(to:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Indicate whether the content of <code><a href="../Structs/AnyDifferentiable.html#/s:13DifferenceKit17AnyDifferentiableV4baseypvp">base</a></code> is equals to the content of the given source value.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@inlinable</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">isContentEqual</span><span class="p">(</span><span class="n">to</span> <span class="nv">source</span><span class="p">:</span> <span class="kt">AnyDifferentiable</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>source</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A source value to be compared.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>A Boolean value indicating whether the content of <code><a href="../Structs/AnyDifferentiable.html#/s:13DifferenceKit17AnyDifferentiableV4baseypvp">base</a></code> is equals
       to the content of <code><a href="../Structs/AnyDifferentiable.html#/s:13DifferenceKit17AnyDifferentiableV4baseypvp">base</a></code> of the given source value.</p>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:s28CustomDebugStringConvertibleP16debugDescriptionSSvp"></a>
                    <a name="//apple_ref/swift/Property/debugDescription" class="dashAnchor"></a>
                    <a class="token" href="#/s:s28CustomDebugStringConvertibleP16debugDescriptionSSvp">debugDescription</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        
                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">debugDescription</span><span class="p">:</span> <span class="kt">String</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </section>

      </article>
    </div>
    <section class="footer">
      <p>&copy; 2019 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-10-21)</p>
      <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
    </section>
  </body>
</div>
</html>
